<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // const promise=new Promise(function(resolve,reject){
        //     setTimeout(resolve,1000);
        // })
        // promise.then(function(){
        //     console.log(1+'秒后出现');
        //     return promise;
        // })

        // Promise实现异步调用的方法
        // const promise = new Promise(resolve => {
        //     setInterval(resolve, 1000);
        // })
        // promise.then(resolve => {
        //     console.log(1 + '秒后出现');

        //     return new Promise(resolve => {
        //         setTimeout(resolve, 1000)
        //     })
        // }).then(resolve => {
        //     console.log(2 + '秒后出现')
        //     return new Promise(resolve=>{
        //         setTimeout(resolve,1000)
        //     })
        // })

        function fn() {
            return new Promise(resolve => {
                setTimeout(resolve,1000)
            })
        }
        fn().then(resolve=>{
            console.log(1+'秒后出现')
            return fn()
        }).then(resolve=>{
            console.log(2+'秒后出现')
            return fn()
        })
        


    </script>
</body>

</html>